package router

import (
	_ "admin/docs"

	"admin/src/log"
	"admin/src/middle"

	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	gs "github.com/swaggo/gin-swagger"
)

func InitRouter() {
	r := gin.Default()
	//启动swagger在线文档
	r.GET("/swagger/*any", gs.WrapHandler(swaggerFiles.Handler))
	//初始化密钥路由
	InitPublicKey(r)
	api := r.Group("/api")
	//检查token中间件
	api.Use(middle.CheckToken())

	InitUserRouter(api)

	err := r.Run(":8080")
	if err != nil {
		log.Logger.Error("数据库连接失败:" + err.Error())
		return
	}
}
